<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="种类规格" bodyClass="gray-bg animated fadeInRight" isAnimation=false libs=["table","zTree","layout-latest"]/>
<div class="ui-layout-west">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-grid"></i> 种类规格分类
            </div>
            <div class="box-tools pull-right">
                <!--<a type="button" class="btn btn-box-tool" href="#" onclick="comp()" title="公司管理"><i class="fa fa-edit"></i></a>-->
                <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新信息"><i class="fa fa-refresh"></i></button>
            </div>
            <div class="box-tools pull-left">
                <button type="button" class="btn btn-success" id="listAdd" onclick="listAdd(testId)" title="新增" >新增</button>
                <button type="button" class="btn btn-primary single " id="listEdit"  onclick="listEdit(testId)" title="编辑">编辑</button>
                <button type="button" class="btn btn-danger multiple " id="listDel" onclick="listDel(testId)" title="删除">删除</button>

            </div>
        </div>
        <div class="ui-layout-content">
            <div id="tree" class="ztree"></div>
        </div>
    </div>
</div>
<div class="ui-layout-center">
    <div class="container-div">
        <!--<div class="row">-->
        <!--<div class="col-sm-12 search-collapse">-->
        <!--<@f.form id="dept-form">-->
        <!--<input id="equipmentType" name="equipmentType" value="" type="hidden">-->
        <!--<input id="meteringUnit" name="meteringUnit" value="" type="hidden">-->
        <!--<input id="depositAddr" name="depositAddr" value="" type="hidden">-->
        <!--<input id="useDepartment" name="useDepartment" value="" type="hidden">-->
        <!--<input id="safekeeping" name="safekeeping" value="" type="hidden">-->
        <!--<input id="increase" name="increase" value="" type="hidden">-->
        <!--<input id="usages" name="usages" value="" type="hidden">-->
        <!--<input id="accumulatedDepreciation" name="accumulatedDepreciation" value="" type="hidden">-->

        <!--</@f.form>-->
        <!--</div>-->

        <div class="row">
            <div class="col-sm-12 search-collapse">
                <@f.form id="module-form">
                <input id="name" name="name" value="" type="hidden">
                <!--我们在body中加入一个div，里面放入一个table-->
                <div style="display:none" id="test">
                    <h4>高级查询</h4>
                    <hr>
                    <table class="table table-striped">
                        <tbody>
                        <tr>
                            <td><@ctx.i18n text = "编号"/>：</td>
                            <td><input type="text" class="form-control" name="configureCode2"  placeholder="请输入检测类别"></td>
                            <td><@ctx.i18n text = "种类名称"/>：</td>
                            <td><input type="text" class="form-control" name="configureName2"  placeholder="请输入检测名称"></td>
                        </tr>
                        <tr>
                            <td><@ctx.i18n text = "规格"/>：</td>
                            <td><input type="text" class="form-control" name="specifications1"  placeholder="请输入规格种类"></td>
                            <td><@ctx.i18n text = "直径"/>：</td>
                            <td><input type="text" class="form-control" name="specifications2"  placeholder="请输入使用部位"></td>
                        </tr>
                        <tr>
                            <td class="select-time" colspan="4"><label>录入时间：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input type="text" name="beginTime" class="layui-input" placeholder="请输入选择时间" id="timeSelect" style="width: 150px" ><label>--</label><input type="text" name="endTime" class="layui-input" placeholder="请输入选择时间" id="timeSelect2" style="width: 150px"></td>
                        </tr>
                        </tbody>
                        <tfoot>
                        <tr>
                            <td colspan="2" align="center"><a class="btn btn-primary btn-rounded btn-sm" id="search" onclick="$.table.search()"><i class="fa fa-search"></i>  <@ctx.i18n text = "查询"/></a></td>
                            <td colspan="2" align="center"><a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i> <@ctx.i18n text = "重置"/></a></td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
                <!--里面放入一个table-->
                <div class="select-list">
                    <ul>
                        <li >
                            <label>编号： </label>
                            <@f.input  name="useDepartment" value=""/>
                        </li>
                        <li>
                            <@ctx.i18n text = "种类名称"/>：
                            <input type="text" class="form-control" name="safekeeping" value=""/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>  <@ctx.i18n text = "查询"/></a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i> <@ctx.i18n text = "重置"/></a>
                            <a class="btn btn-primary btn-rounded btn-sm" id="searchall"><i class="fa fa-search"></i>  <@ctx.i18n text = "高级查询"/></a>
                        </li>
                    </ul>
                </div>
            </@f.form>
        </div>
        <@table id="bootstrap-table">
        <input id="testId" name="testId" value="" type="hidden" >
        <@shiro.hasPermission name="pms:configureList:add">
        <a class="btn btn-success" onclick="add(testId)"><i class="fa fa-plus"></i>&nbsp;<@ctx.i18n text = "新增"/></a>
    </@shiro.hasPermission>
    <@shiro.hasPermission name="pms:configureList:edit">
    <a class="btn btn-primary single disabled" onclick="opt.operate.edit(testId)"><i class="fa fa-pencil-square-o"></i>&nbsp;<@ctx.i18n text = "修改"/></a>
</@shiro.hasPermission>
<@shiro.hasPermission name="pms:configureList:del">
<a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()">
    <i class="fa fa-remove"></i> <@ctx.i18n text = "删除"/>
</a>
</@shiro.hasPermission>
<!--<@shiro.hasPermission name="pms:template:export">-->
<!--<a class="btn btn-warning" onclick="$.table.exportExcel()">-->
    <!--<i class="fa fa-download"></i> 导出-->
<!--</a>-->
<!--</@shiro.hasPermission>-->
</@table>
</div>
</div>
</div>
<@footer>
<script type="text/javascript">

    var editFlag = "${permission.hasPermi('pms:configureList:edit')}";
    var delFlag = "${permission.hasPermi('pms:configureList:del')}";
    var add1Flag = "${permission.hasPermi('pms:configureList:add')}";
    var resetPwdFlag = "${permission.hasPermi('pms:configureList:resetPwd')}";
    var visible = ${permission.isPermitteds("sys:user:edit,sys:user:del,sys:user:resetPwd")?string('true', 'false')};
    var datas = ${dict.getDictListJson('sys_user_show_hide')};
    var prefix = baseURL + 'pms/configureList';
    var prefix1 = baseURL + 'pms/test';
    $(function() {
        /*初始化页面布局*/
        var panehHidden = false;
        if ($(this).width() < 767) {
            panehHidden = true;
        }
        /*初始化布局*/
        $('body').layout({
            initClosed: panehHidden
            , west__size: 190
            ,west__fxSpeed_size:			"fast"	// 'fast' animation when resizing west-pane
            ,west__fxSpeed_open:			1000	// 1-second animation when opening west-pane
            ,west__fxSettings_open:		{ easing: "easeOutBounce" } // 'bounce' effect when opening
            ,west__fxName_close:			"none"	// NO animation when closing west-pane
        });
        /*加载 树、树表格*/
        initTable();
        initLeftZtree();
    });

    function initTable() {
        /* 初始表格对象 */
        var options = {
            url: prefix + "/list",
            addUrl: prefix + "/add{id}",
            editUrl: prefix + "/edit/{id}",
            delUrl: prefix + "/del",
            viewUrl: prefix + "/view/{id}",
            exportUrl:  prefix + "/export",
            clickToSelect: false,

            // resizable: true,
            pageSize: 12,
            pageList: [12, 24, 36],
            sortName: "id",
            uniqueId: "id", /* 唯一ID */
            modalName: "种类规格",
            columns: [
                // {field: 'selectItem', radio: true},
                {title: $.i18n.prop("序号"), width: 5, align: "center", formatter: function (value, row, index) {
                        return $.table.serialNumber(index);}},

                {field : 'configureCode',title : '<@ctx.i18n text = "编号"/>'},
                {field : 'configureName',title : '<@ctx.i18n text = "规格型号"/>'},
                {field : 'specifications1',title : '<@ctx.i18n text = "规格"/>'},
                {field : 'specifications2',title : '<@ctx.i18n text = "直径"/>'},
                {field : 'createTime',title : '<@ctx.i18n text = "录入时间"/>'},
                {title:"<@ctx.i18n text = "操作"/>",align: 'left',class:'action',formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "关联流程表单"/>" onclick="taskFrom(\'' + row.id + '\')"><i class="fa icon-organization"></i></a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick=" opt.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i><@ctx.i18n text = "编辑"/></a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + delFlag + '" href="javascript:void(0)" onclick="opt.operate.del(\'' + row.id + '\')"><i class="fa fa-remove"></i> <@ctx.i18n text = "删除"/></a>');
                        // actions.push('<a class="btn btn-success btn-xs ' + add1Flag + '" href="javascript:void(0)" onclick="repair(\'' + row.id + '\')"><i class="fa fa-edit"></i><@ctx.i18n text = "设备维修"/></a> ');
                        return actions.join('');
                    }}
            ]
        };
        $.table.init(options);
    }
    var leftButTag = false;
    function popupRight(id){
        opt.modal.popupRight("用户信息",prefix + "/view/"+id,delFlag == '',opt.operate.edit,id);
    }
    /* 用户管理-重置密码 */
    function repair(id) {
        console.log("111111")
        console.log(id)
        console.log("11111111")
        opt.modal.openTab("设备维修",prefix + "/repair/"+id);
    }

    /* 用户管理-重置密码 */
    function add(id) {
        var ids=id.value
        if(ids==""){
            alert('需要选择模板列表！');
            return false;
        }
        console.log("1111111111111111")
        opt.modal.open("新增种类规格",prefix + "/add/"+ids);
    }


    /*初始化左侧树*/
    function initLeftZtree() {
        var options = {
            url: prefix1+"/treeData",
            displayLen: 12,
            expandLevel:1,
            onClick : onClick,
            check: {
                enable: false
            }
        };
        $.tree.init(options);
    }

    /* 点击左侧数节点 回调事件 刷新表格*/
    function onClick(event, treeId, treeNode) {
        leftButTag = true;
        console.log(treeNode);
        console.log(treeNode.name);
        console.log(treeNode.pId);
        $("#testId").val("");

        if(treeNode.pId){
            var  pid=treeNode.pId;
        }
        $("#testId").val(treeNode.id);

        $.table.search();

    }

    /* 左侧数刷新事件*/
    $('#btnRefresh').click(function() {
        initLeftZtree();
    });

    /* 左侧树展开事件 */
    $('#btnExpand').click(function() {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });

    /* 左侧树折叠事件 */
    $('#btnCollapse').click(function() {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });

    function  listAdd(id){
        var ids=0
        if(id.value){
            ids=id.value
        }
        opt.modal.open("添加种类规格分类",prefix1 + "/add/"+ids);
    }
    /* 左侧新增事件 */
    function  listEdit(id){
        console.log("111111")
        console.log(id.value)
        console.log("11111111")
        var ids=id.value
        opt.modal.open("编辑种类规格分类",prefix1 + "/edit/"+ids);
    }
    /* 左侧新增事件 */
    function  listDel(id){
        console.log("111111")
        console.log(id.value)
        console.log("11111111")
        var ids=id.value
        opt.modal.confirm("确认要删除吗?", function() {
            opt.operate.post(prefix1 + "/del", { "id": ids});
        })

    }

    function comp() {
        var url = baseURL + "sys/dept";
        opt.modal.openTab("机构管理", url);
    }

    /* 点击树组件 回调事件案例 回调方法名固定 刷新表格*/
    /**
     *  id 为组件id
     *  event 为组件点击按钮名称 ok 确定 clear 清除 cancel 取消
     *  index 弹出窗口index
     *  layero
     *  nodes 确认事件传的参数
     **/
    function treeCallback(id, event, index, layero, nodes) {
        if(id == "compId"){
            if(event == "ok"){
                /* 点击确认按钮直接刷新表格*/
                $.table.search();
            }
        }
    }


</script>
<script>
    /*弹出层*/
    $('#searchall').on('click', function(){
        // layer.msg('hello');
        layer.open({
            type: 1,
            title:'组合查询',
            area: ['600px', '450px'],
            content: $("#test"),
            shade:0.0,
            btn: ['关闭'], //只是为了演示,
            btn2: function(){
                layer.closeAll();
            }
        });
    });
    /*弹出层点击查询按钮关闭弹出层*/
    $('#search').on('click',function () {
        layer.closeAll()
    })

    /*弹出层时间选择控件*/
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#timeSelect'  // 输出框id
            ,format: 'yyyy-MM-dd'
            ,trigger:'click'
        });
    });
    /*弹出层时间选择控件*/
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#timeSelect2'  // 输出框id
            ,format: 'yyyy-MM-dd'
            ,trigger:'click'
        });
    });
</script>
</@footer>
</@pageTheme>